package com.time.admin.infra.basic.service.impl;

import com.time.admin.infra.basic.entity.Comment;
import com.time.admin.infra.basic.mapper.CommentDao;
import com.time.admin.infra.basic.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 评论表(Comments)表服务实现类
 *
 * @author HuangQi
 * @since 2025-09-30 16:15:04
 */
@Service("commentService")
public class CommentServiceImpl implements CommentService {
    @Autowired
    private CommentDao commentDao;

    /**
     * 通过ID查询单条数据
     *
     * @param commentId 主键
     * @return 实例对象
     */
    @Override
    public Comment queryById(Long commentId) {
        return this.commentDao.queryById(commentId);
    }

    /**
     * 新增数据
     *
     * @param comment 实例对象
     * @return 实例对象
     */
    @Override
    public Integer insert(Comment comment) {
        return this.commentDao.insert(comment);
    }

    /**
     * 修改数据
     *
     * @param comment 实例对象
     * @return 实例对象
     */
    @Override
    public Integer update(Comment comment) {
        return this.commentDao.update(comment);
    }

    /**
     * 通过主键删除数据
     *
     * @param commentId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long commentId) {
        return this.commentDao.deleteById(commentId) > 0;
    }

    @Override
    public Integer count(Comment comment) {
        return Math.toIntExact(this.commentDao.count(comment));
    }

    @Override
    public List<Comment> queryPageByCondition(Comment comment, int start, int pageSize) {
        return this.commentDao.queryAllByLimit(comment, start, pageSize);
    }
}
